package com.css.common.security.config;

import cn.hutool.json.JSONUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @author chenhui
 * @description api配置
 */
@Slf4j
@Data
@Component
@ConfigurationProperties(prefix = "api")
public class ApiConfig {
    //鉴权启用标志
    private Boolean jqqybz;

    //测试用户
    private Set<String> userTest;

    //开启校验
    private Boolean verity;

//    private List<AppidKey> appidKey;//
//
//    public String getKeyById(String appid){
//        if(BaseUtil.isNull(appid))return null;
//        AppidKey idKey = appidKey.stream().filter(ak->appid.equals(ak.getAppid())).findFirst().orElse(null);
//        return BaseUtil.isNull(idKey)?null:idKey.getAppkey();
//    }

    public boolean isTestUser(String yhm) {
        log.info("测试用户：{}", JSONUtil.toJsonStr(userTest));
        return userTest.contains(yhm);
    }

    @Data
    static class AppidKey {

        private String appid;

        private String appkey;
    }


}
